package com.example.work2

import android.annotation.SuppressLint
import android.content.Intent
import android.os.Bundle
import android.widget.Button
import android.widget.EditText
import androidx.appcompat.app.AppCompatActivity

class MainActivity3 : AppCompatActivity() {

    private lateinit var editTextName: EditText
    private lateinit var editTextGender: EditText
    private lateinit var editTextPhone: EditText
    private lateinit var buttonSaveInfo: Button

    @SuppressLint("MissingInflatedId")
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_info_edit)

        editTextName = findViewById(R.id.editTextName)
        editTextGender = findViewById(R.id.editTextGender)
        editTextPhone = findViewById(R.id.editTextPhone)
        buttonSaveInfo = findViewById(R.id.buttonSaveInfo)


        editTextName.setText("刘渝铭")
        editTextGender.setText("男")
        editTextPhone.setText("1234567890")

        buttonSaveInfo.setOnClickListener {

            val name = editTextName.text.toString()
            val gender = editTextGender.text.toString()
            val phone = editTextPhone.text.toString()


            val playerInfo = PlayerInfo(name, gender, phone, 10) // 更新信息


            val intent = Intent(this, MainActivity::class.java)
            startActivity(intent)
        }
    }
}